/**
 * @category  输入五位以上连续的数字和字母校验
 * @description  密码规则校验
 * @param str {string}
 * @example consecutiveFive(str) => boolean
 */
export default function consecutiveFive(str: string): boolean {
    if (str) {
        const arr: any = str.split('')
        let flag = true
        for (let i = 1; i < arr.length - 1; i++) {
            const firstIndex = arr[i - 1].charCodeAt()
            const secondIndex = arr[i].charCodeAt()
            const thirdIndex = arr[i + 1].charCodeAt()
            const fourIndex = arr[i + 2]?.charCodeAt()
            const fiveIndex = arr[i + 3]?.charCodeAt()
            const result_1 = secondIndex - firstIndex
            const result_2 = thirdIndex - secondIndex
            const result_3 = fourIndex - thirdIndex
            const result_4 = fiveIndex - fourIndex
            if (result_1 == 1 && result_2 == 1 && result_3 == 1 && result_4 == 1) {
                flag = false
            }
            if (result_1 == -1 && result_2 == -1 && result_3 == -1 && result_4 == -1) {
                flag = false
            }
        }
        return flag
    }
    return false
}
